summaryrefslogtreecommitdiff
path: root/ui/routes/(login)/invite/[invite]/+page.svelte
blob: 04341e52af93e7cbdefc72026b46148072d1832f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<script>
  import { goto } from '$app/navigation';
  import * as api from '$lib/apiServer';

  import LogIn from '$lib/components/LogIn.svelte';

  let { data } = $props();

  async function acceptInvite(inviteId, username, password) {
    const response = await api.acceptInvite(inviteId, username, password);
    if (200 <= response.status && response.status < 300) {
      await goto('/');
    }
  }
</script>

{#await data.invite}
  <div class="invite-text">
    <p>Loading invitation…</p>
  </div>
{:then invite}
  <div class="invite-text">
    <p>Hi there! {invite.issuer} invites you to the conversation.</p>
  </div>
  <LogIn logIn={async (username, password) => acceptInvite(invite.id, username, password)} />
{/await}